package com.situ.mall.web.service;

import com.mall.common.util.JsonResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;

/**
 * 数据分析服务 Feign 客户端
 */
@FeignClient(name = "analytics-api", path = "/api/analytics", contextId = "analytics-api")
public interface AnalyticsFeignService {

    /**
     * 获取销售关键指标
     */
    @PostMapping("/sale-key-metrics")
    ResponseEntity<JsonResult<?>> getSaleKeyMetrics(@RequestBody TimeSearchRequest timeSearch);

    /**
     * 获取支付方式统计
     */
    @PostMapping("/sale-pay-type")
    ResponseEntity<JsonResult<?>> getSalePayType(@RequestBody TimeSearchRequest timeSearch);

    /**
     * 获取商品关键指标
     */
    @PostMapping("/product-key-metrics")
    ResponseEntity<JsonResult<?>> getProductKeyMetrics(@RequestBody TimeSearchRequest timeSearch);

    /**
     * 获取商品库存统计
     */
    @PostMapping("/product-stock")
    ResponseEntity<JsonResult<?>> getProductStock(@RequestBody TimeSearchRequest timeSearch);

    /**
     * 获取商品分类统计
     */
    @PostMapping("/product-category")
    ResponseEntity<JsonResult<?>> getProductCategory(@RequestBody TimeSearchRequest timeSearch);

    /**
     * 获取用户统计信息
     */
    @GetMapping("/user-status")
    ResponseEntity<JsonResult<?>> getUserStatus();

    /**
     * 时间搜索请求DTO
     */
    class TimeSearchRequest {
        private LocalDate startDate;
        private LocalDate endDate;

        public TimeSearchRequest() {}

        public TimeSearchRequest(LocalDate startDate, LocalDate endDate) {
            this.startDate = startDate;
            this.endDate = endDate;
        }

        // getters and setters
        public LocalDate getStartDate() { return startDate; }
        public void setStartDate(LocalDate startDate) { this.startDate = startDate; }

        public LocalDate getEndDate() { return endDate; }
        public void setEndDate(LocalDate endDate) { this.endDate = endDate; }
    }
} 